//
//  YTStashForewarningModel.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/11/14.
//

#import "YTStashForewarningModel.h"

@implementation YTStashForewarningModel
+ (NSDictionary *)modelCustomPropertyMapper {
    return @{@"ID":@[@"id"],
             @"LowerLimit":@[@"lowerLimit"],
    };
}

-(NSString *)productNormsStr{
    if(!_productNormsStr){
        _productNormsStr = [NSString stringWithFormat:@"%@/%@",self.productNorms,self.normsName];
    }
    return _productNormsStr;
}

- (CGFloat)categoryNameH{
    if(_categoryNameH == 0){
        _categoryNameH = [DTKTool textWithtitle:self.categoryName andSize:CGSizeMake(kwt(270), 10000) andFout:kFont(16)].height;
        if(_categoryNameH < kwt(16)){
            _categoryNameH = kwt(16);
        }
    }
    return _categoryNameH;
}
- (CGFloat)productBrandH{
    if(_productBrandH == 0){
        _productBrandH = [DTKTool textWithtitle:self.productBrand andSize:CGSizeMake(kwt(270), 10000) andFout:kFont(16)].height;
        if(_productBrandH < kwt(16)){
            _productBrandH = kwt(16);
        }
    }
    return _productBrandH;
}
- (CGFloat)productNormsStrH{
    if(_productNormsStrH == 0){
        _productNormsStrH = [DTKTool textWithtitle:self.productNormsStr andSize:CGSizeMake(kwt(270), 10000) andFout:kFont(16)].height;
        if(_productNormsStrH < kwt(16)){
            _productNormsStrH = kwt(16);
        }
    }
    return _productNormsStrH;
}
- (CGFloat)expiratDateH{
    if(_expiratDateH == 0){
        _expiratDateH = [DTKTool textWithtitle:self.expiratDate andSize:CGSizeMake(kwt(270), 10000) andFout:kFont(16)].height;
        if(_expiratDateH < kwt(16)){
            _expiratDateH = kwt(16);
        }
    }
    return _expiratDateH;
}
- (CGFloat)HeaderViewH{
    return kwt(109 + 15 * 4) + self.categoryNameH + self.productBrandH + self.productNormsStrH + self.expiratDateH;
}

- (CGFloat)areaNameH{
    if(_areaNameH == 0){
        _areaNameH = [DTKTool textWithtitle:self.areaName andSize:CGSizeMake(kwt(256), 10000) andFout:kFont(16)].height;
        if(_areaNameH < kwt(16)){
            _areaNameH = kwt(16);
        }
    }
    return _areaNameH;
}

- (CGFloat)addressNameH{
    if(_addressNameH == 0){
        _addressNameH = [DTKTool textWithtitle:self.addressName andSize:CGSizeMake(kwt(256), 10000) andFout:kFont(16)].height;
        if(_addressNameH < kwt(16)){
            _addressNameH = kwt(16);
        }
    }
    return _addressNameH;
}

- (CGFloat)shelfNumberH{
    if(_shelfNumberH == 0){
        _shelfNumberH = [DTKTool textWithtitle:self.shelfNumber andSize:CGSizeMake(kwt(256), 10000) andFout:kFont(16)].height;
        if(_shelfNumberH < kwt(16)){
            _shelfNumberH = kwt(16);
        }
    }
    return _shelfNumberH;
}

- (CGFloat)DetailsCellH{
    return kwt(10 + 48 + 16 * 9) + self.areaNameH + self.addressNameH + self.shelfNumberH;
}
@end
@implementation YTStashForewarningScreenModel
- (NSMutableDictionary *)SXDict{
    NSMutableDictionary * dict = [NSMutableDictionary dictionary];
    if(self.type != 0){
        [dict setObject:@(self.type) forKey:@"type"];
    }
    
    if(self.startTime.length > 0){
        [dict setObject:self.startTime forKey:@"startTime"];
        [dict setObject:self.endTime forKey:@"endTime"];
    } else {
        [dict setObject:self.monthTime forKey:@"monthTime"];
    }
    [dict setObject:self.queryParam forKey:@"queryParam"];
    [dict setObject:self.categoryId forKey:@"categoryId"];

    return dict;
}
- (NSString *)monthTime{
    if(!_monthTime){
        _monthTime = [NSDate br_stringFromDate:[NSDate new] dateFormat:@"yyyy-MM"];
    }
    return _monthTime;
}
@end
